import type { PaginationProps } from 'element-plus'
import type { PropType } from 'vue'
import type { BasicColumn, FetchSetting } from './types/table'
import { FETCH_SETTING } from './const'
import type { Fn, Recordable } from '@/types/global'
import { propTypes } from '@/types/propTypes'
import type { FormProps } from '@/components/BasicForm/src/types/form'

export const basicProps = {
  api: {
    type: Function as PropType<(...arg: any[]) => Promise<any>>,
    default: null,
  },
  // 立即请求接口
  immediate: { type: Boolean, default: true },
  // 额外的请求参数
  searchInfo: {
    type: Object as PropType<Recordable>,
    default: null,
  },
  columns: {
    type: Array as PropType<BasicColumn[]>,
    default: () => [],
  },
  headerAlign: propTypes.string.def('left'),
  align: propTypes.string.def('left'),
  showIndexColumn: { type: Boolean, default: true },
  border: propTypes.string.def('full'),
  pagination: {
    type: [Object, Boolean] as PropType<PaginationProps | boolean>,
    default: null,
  },
  loading: propTypes.bool,
  // 表单配置
  formConfig: {
    type: Object as PropType<Partial<FormProps>>,
    default: {
      submitButtonOptions: {
        plain: true,
      },
      resetButtonOptions: {
        plain: true,
      },
    },
  },
  handleSearchInfoFn: {
    type: Function as PropType<Fn>,
    default: null,
  },
  fetchSetting: {
    type: Object as PropType<FetchSetting>,
    default: () => {
      return FETCH_SETTING
    },
  },
  useSearchForm: propTypes.bool.def(true),
  dataSource: {
    type: Array as PropType<Recordable[]>,
    default: null,
  },
  autoCreateKey: propTypes.bool.def(true),
  rowKeyd: {
    type: [String, Function] as PropType<string | ((record: Recordable) => string)>,
    default: '',
  },
  // 是否叠加索引
  reserveIndex: propTypes.bool.def(false),
  stripe: propTypes.bool.def(false), //是否为斑马纹 table
  canResize: { type: Boolean, default: true }, //是否可以自适应高度
  height: {
    type: [String, Number],
    default: 'auto',
  },
  columnConfig: {
    type: Object,
    default: { resizable: true, minWidth: 'auto' },
  },
  rowConfig: {
    type: Object,
    default: { isCurrent: true, isHover: true },
  },
  headerRowStyle: {
    type: Object,
    default: {},
  },
  autoResize: propTypes.bool.def(true),
  //   clickToRowSelect: { type: Boolean, default: true },
  //   showTableList: { type: Boolean, default: true },
  //   isTreeTable: Boolean,
  //   tableSetting: propTypes.shape<TableSetting>({}),
  //   inset: Boolean,
  //   sortFn: {
  //     type: Function as PropType<(sortInfo: SorterResult) => any>,
  //     default: DEFAULT_SORT_FN
  //   },
  //   filterFn: {
  //     type: Function as PropType<(data: Partial<Recordable<string[]>>) => any>,
  //     default: DEFAULT_FILTER_FN
  //   },
  //   showTableSetting: Boolean,
  //   autoCreateKey: { type: Boolean, default: true },
  //   striped: { type: Boolean, default: true },
  //   showSummary: Boolean,
  //   summaryFunc: {
  //     type: [Function, Array] as PropType<(...arg: any[]) => any[]>,
  //     default: null
  //   },
  //   summaryData: {
  //     type: Array as PropType<Recordable[]>,
  //     default: null
  //   },
  //   indentSize: propTypes.number.def(24),
  //   canColDrag: { type: Boolean, default: true },

  //   beforeFetch: {
  //     type: Function as PropType<Fn>,
  //     default: null
  //   },
  //   afterFetch: {
  //     type: Function as PropType<Fn>,
  //     default: null
  //   },

  //   emptyDataIsShowTable: { type: Boolean, default: true },

  //   // 默认的排序参数
  //   defSort: {
  //     type: Object as PropType<Recordable>,
  //     default: null
  //   },

  //   indexColumnProps: {
  //     type: Object as PropType<BasicColumn>,
  //     default: null
  //   },
  //   actionColumn: {
  //     type: Object as PropType<BasicColumn>,
  //     default: null
  //   },
  //   ellipsis: { type: Boolean, default: true },
  //   isCanResizeParent: { type: Boolean, default: false },
  //   canResize: { type: Boolean, default: true },
  //   clearSelectOnPageChange: propTypes.bool,
  //   resizeHeightOffset: propTypes.number.def(0),
  //   rowSelection: {
  //     type: Object as PropType<TableRowSelection | null>,
  //     default: null
  //   },
  //   title: {
  //     type: [String, Function] as PropType<string | ((data: Recordable) => string)>,
  //     default: null
  //   },
  //   titleHelpMessage: {
  //     type: [String, Array] as PropType<string | string[]>
  //   },
  //   maxHeight: propTypes.number,

  //   rowClassName: {
  //     type: Function as PropType<(record: TableCustomRecord<any>, index: number) => string>
  //   },
  //   scroll: {
  //     type: Object as PropType<{ x: number | string | true; y: number | string }>,
  //     default: null
  //   },
  //   beforeEditSubmit: {
  //     type: Function as PropType<(data: { record: Recordable; index: number; key: string | number; value: any }) => Promise<any>>
  //   }
}
